using Engine;
using Game;

namespace RuthlessConquest {
    public class AliensAttackMessageWidget : CanvasWidget {
        public LabelWidget LabelWidget;

        public double MessageTime;

        public AliensAttackMessageWidget() {
            IsHitTestVisible = false;
            IsVisible = false;
            LabelWidget = new LabelWidget { DropShadow = true };
            Children.Add(LabelWidget);
        }

        public void SetMessage(string text) {
            MessageTime = Time.FrameStartTime;
            LabelWidget.Text = text;
            LabelWidget.Color = Color.Transparent;
            IsVisible = true;
        }

        public override void Update() {
            float num = (float)(Time.FrameStartTime - MessageTime);
            float num2 = MathUtils.Saturate(MathUtils.Min(6f * num, 0.4f * (5f - num)));
            LabelWidget.Color = Color.White * num2;
            if (num2 <= 0f) {
                IsVisible = false;
            }
        }
    }
}